#include<iostream>
#include <stdio.h>
#include <string.h> 
using namespace std;


const char* keywords[8] = {
	"int","void","if","else","while","break","continue","return"
};

const char sg_op[12] = {'+','-','*','/','%','(',')','{','}',';',',','\0'};

const char db_op_start[7] = { '&','|','<','>','=','!' ,'\0'};

char current_ch;

void next_ch() { current_ch = cin.get(); }

void pre()
{
	while (1) {
		while (isspace(current_ch)) { next_ch(); }//跳过空格，制表符，换行符（也是空白符）
		if (current_ch == '/')
		{
			next_ch();
			if (current_ch == '/')//处理单行注释int
			{
				while (current_ch != '\n' && current_ch != EOF)
				{
					next_ch();
				}
				if (current_ch == '\n')
				{
					next_ch();
				}
			}

			else if (current_ch == '*')//大段注释
			{
				next_ch();
				while (1)
				{
					if (current_ch == '*')
					{
						next_ch();
						if (current_ch == '/')
						{
							next_ch();
							break;
						}
					}
					else if (current_ch == EOF)
					{
						break;
					}
					else
					{
						next_ch();
					}
				}
			}
			else//标准除号
			{
				cin.unget();//回退，将多读的字符（current_ch)放回流中
				current_ch = '/';
				break;
			}
		}
		else//如果不是注释，跳出
		{
			break;
		}
	}
}

int main()
{
	int num = 0;

	next_ch();

	while (current_ch != EOF)
	{
		pre();//预处理

		if (current_ch == EOF)//预处理后如果结束则跳出循环
		{
			break;
		}

		//正式处理
		//识别标识符和关键字
		if (isalpha(current_ch) || current_ch == '_')
		{
			char word[100] = { 0 };
			int i = 0;
			while (isalpha(current_ch) || isdigit(current_ch) || current_ch == '_')
			{
				word[i] = current_ch;
				i++;
				next_ch();
			}
			word[i]='\0';
			//判断是否为关键词
			int is_keyword = 0;
			for (int n = 0;n < 8;n++)
			{
				if (strcmp(word,keywords[n])==0)
				{
					is_keyword = 1;
					cout << num << ":" << "\'" << word << "\'" << ":" << "\"" << word << "\"" << endl;
				}
			}
			if (is_keyword == 0)
			{
				cout<<num<< ":" <<"Ident"<<":"<< "\"" << word << "\"" << endl;
			}
			num++;
		}
		//判断是否为整数（正负）
		else if (isdigit(current_ch) || current_ch == '-' && isdigit(cin.peek()))
		{
			char number[100] = { 0 };
			int i = 0;
			if (current_ch == '-')
			{
				number[i] = current_ch;
				i++;
				next_ch();
				cout << num << ":" <<"\'"<< "-"<<"\'" << ":" << "\"" << "-" << "\"" << endl;
			}
			else
			{
				while(isdigit(current_ch))
				{
					number[i] = current_ch;
					i++;
					next_ch();
				}
				cout << num << ":" << "IntConst" << ":" << "\"" << number << "\"" << endl;
			}
			num++;
		}
		//判断是否为单字符运算符
		else if (strchr(sg_op, current_ch) != NULL)
		{
			cout << num << ":" << "\'" << current_ch << "\'" << ":" << "\"" << current_ch << "\"" << endl;
			next_ch();
			num++;
		}
		else if (strchr(db_op_start, current_ch) != NULL)
		{
			if (current_ch == '&')
			{
				if (cin.peek() == '&')
				{
					next_ch();
					next_ch();
					cout << num << ":" << "\'" << "&&" << "\'" << ":" << "\"" << "&&" << "\"" << endl;
				}
				else
				{
					cout << num << ":" << "\'" << current_ch << "\'" << ":" << "\"" << current_ch << "\"" << endl;
					next_ch();
				}
			}
			else if (current_ch == '|')
			{
				if (cin.peek() == '|')
				{
					next_ch();
					next_ch();
					cout << num << ":" << "\'" << "||" << "\'" << ":" << "\"" << "||" << "\"" << endl;
				}
				else
				{
					cout << num << ":" << "\'" << current_ch << "\'" << ":" << "\"" << current_ch << "\"" << endl;
					next_ch();
				}
			}
			else if (current_ch == '<')
			{
				if (cin.peek() == '=')
				{
					next_ch();
					next_ch();
					cout << num << ":" << "\'" << "<=" << "\'" << ":" << "\"" << "<=" << "\"" << endl;
				}
				else
				{
					cout << num << ":" << "\'" << current_ch << "\'" << ":" << "\"" << current_ch << "\"" << endl;
					next_ch();
				}
			}
			else if (current_ch == '>')
			{
				if (cin.peek() == '=')
				{
					next_ch();
					next_ch();
					cout << num << ":" << "\'" << ">=" << "\'" << ":" << "\"" << ">=" << "\"" << endl;
				}
				else
				{
					cout << num << ":" << "\'" << current_ch << "\'" << ":" << "\"" << current_ch << "\"" << endl;
					next_ch();
				}
			}
			else if (current_ch == '=')
			{
				if (cin.peek() == '=')
				{
					next_ch();
					next_ch();
					cout << num << ":" << "\'" << "==" << "\'" << ":" << "\"" << "==" << "\"" << endl;
				}
				else
				{
					cout << num << ":" << "\'" << current_ch << "\'" << ":" << "\"" << current_ch << "\"" << endl;
					next_ch();
				}
			}
			else if (current_ch == '!')
			{
				if (cin.peek() == '=')
				{
					next_ch();
					next_ch();
					cout << num << ":" << "\'" << "!=" << "\'" << ":" << "\"" << "!=" << "\"" << endl;
				}
				else
				{
					cout << num << ":" << "\'" << current_ch << "\'" << ":" << "\"" << current_ch << "\"" << endl;
					next_ch();
				}
			}
			else
			{
			
			}
			num++;
		}
	}
	return 0;
}
